<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>${(category.name)!"全部分类"}价格/采购/参数/厂家_安装通</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="keyword" content="${(category.name)!"全部分类"}价格,${(category.name)!"全部分类"}采购,${(category.name)!"全部分类"}参数,${(category.name)!"全部分类"}厂家" />
    <meta name="description" content="安装通为您介绍${(category.name)!"全部分类"}的详细参数、厂家资料、价格行情、优质采购/供应等信息，您还可以找到更多关于${(category.name)!"全部分类"}的产品信息。" />
    <link href="/res/css/mall/mallIndex.css" rel="stylesheet">
    <link href="/res/third/city-picker/css/city-picker.css" rel="stylesheet">
    <style type="text/css">
        .newHeader .top .w1200{
            background-color: #f5f5f5;
        }
        .city-picker-span{
            display: inline-block;
            border-bottom: none;
            margin-left: 10px;
        }
        .city-picker-span > .arrow{
            top: 0px;
            right: 0px;
        }
        .city-picker-span.focus, .city-picker-span.open{
            border:none;
        }
        .city-picker-dropdown{
            text-align: left;
        }
        .laypage_main{
        	text-align: center; 
        }
         
        .laypage_main a:hover {
		    background-color: #222e3c;
		    border-color: #222e3c;
		    color: white;
		} 
    </style>
<body class="selfOfer">
[#include "/front/common/front_headMal.html"]
<div class="w1200 proType">
    <h6  id="topsell" class="bread" style="display: inline-block;margin-right: 15px;">当前位置：首页  <span> > <a onclick="changeCatType(this)" attid="0"  >全部分类</a> </span><span id="firstS" ></span><span id="secondS"></span><span id="thirdS"></span>  </h6>
    <div style="overflow: hidden;">
        <div class="store fll">
            <div class="iterm2">
                <div class="detail">
                    <h4 style="background-color: #f5f5f5;">
                        <span style="margin-left: 15px;">人气商品</span>
                    </h4>
                    <!-- 6个 -->
                    <ul class="hot proType">
                        [#list hots as product ]
                        <li>
                            <p>
                                <a href="/offer/${product.id}.html" target="_blank"  style="width: 185px;">
                                <img src="/res/images/defat.png" original="${product.firstImg!}" />
                                </a>
                            </p>
                            <span>
                                <a href="/offer/${product.id}.html" target="_blank"  >
                                    ${product.name!}
                                </a>
							</span>
                            <strong>￥${product.minMemberPrice?string("0.00")}</strong>
                        </li>
                        [/#list]
                    </ul>
                </div>
            </div>
        </div>
        <div class="store flr">
            <div class="iterm2 proType">
                <div class="duoOuter danXuan" style="position: relative;">
                    <label>分类：</label>
                    <div class="keXuan" id="categorySContainer" data-name="categorySId" style="height: 20px;">

                    </div>
                    <div class="itermChose">
                        
                        <a class="zhanKaiLink" onclick="more(this)">更多<i class="zhanKai"></i></a>
                    </div>
                </div>
                <table style="width: 100%;position: relative;">
                    <caption>
                        <div style="display: inline-block;float: left;height: 40px;">
                            <b class="defaltTab" onclick="switchTab(this)">默认</b>
                            <b class="priceOuter "  id="priceswitch"   onclick="switchTab(this, 'price')">价格
                            	<div style="vertical-align: middle;display: inline-block;">
                            		<i class="price [#if param.orderType?? && param.orderType==1] on [/#if]"  data-sort="1"></i>
                            		<i class="price [#if param.orderType?? && param.orderType==2] on [/#if]" data-sort="2"></i>
                            	</div>
                            </b>
                            <b onclick="switchTab(this, 'num')" id="numswitch"   data-sort="num [#if param.orderType?? && param.orderType==4]desc[/#if]" class="numOuter desc">销量<i class="num"></i></b>
                            <b style="border-left: 1px solid #ebebeb;color: #666;">地区<input id="areaProvince" value="" placeholder="全部地区" style="font-size: medium;"></b>
                        </div>
                        <div class="fanYe">
                            <em style="color: #fca711;" id="pageNo"></em>
                            <em style="margin-left: 0px;" id="pages" ></em>
                            <a id="prevPage" style="border-right: none;" href="javascript:void(0);">&lt;</a>
                            <span class="nav"></span>
                            <a id="nextPage" style="margin-left: -5px;border-left: none;" href="javascript:void(0);">&gt;</a>
                        </div>
                    </caption>
                </table>
                <!--4行-->
                <div id="products">
                </div>


                <div id="laypage" ></div>
            </div>
            <!--新闻资讯分页http://localhost:8088/wqq/info/infoIndex-->
        </div>
    </div>
</div>
<form type="hidden"  method="get" action="/selloffer/"  >

</form>
[#include "/front/common/front_foot.html"]
</body>
<script type="text/html" id="categorysTemplate" >
    {{each list }}
     <dfn  id="catname_{{$value.id}}"   class="categorys" {{if currentcat==$value.id }} style="color: red;"{{/if}} onclick="searchByCategory('{{$value.id}}')"  >{{$value.name}}</dfn>
    {{/each}}
</script>
<script type="text/html" id="template" >
    {{if total==0 }}
            <h3 class="sory" style="margin-top: 20px;">
                <img src="/res/images/oparaStatus/none_03.png"/>抱歉，商家还没上传相关商品信息！
            </h3>
    {{else}}
    <ul   class="proType">
    {{each list }}
		
		<li {{if ($index+1)%4==0 }}style="margin-right:0px;"{{/if}} >
				<a href="/offer/{{$value.id}}.html"  target="_blank" >
                <p>
                    <img alt=""  src="/res/images/defat.png"   original="{{$value.firstImg}}" >
                </p>
				</a>
            <a href="/offer/{{$value.id}}.html"  target="_blank"  title="{{$value.name}}" class="godName product">{{$value.name}}</a>
            <h3>{{$value.minMemberPrice | priceFormat }}</h3>
            <a class="godName com" href="/shop/{{$value.shopid}}" >{{$value.companyName}}</a>
            <div class="opGod" style="width:185px;margin:0px auto;text-align:right;margin-top:10px;">
                [#--<button class="fight" type="button">加入购物车</button>--]
                <button class="fight godCar" type="button" onclick="location.href='/offer/{{$value.id}}.html';"   >查看详情</button>
            </div>
        </li>
    {{/each}}
        </ul>
    {{/if}}
</script>

<script src="/res/third/layer/layer.js"></script>
<script src="/res/third/laypage/laypage.min.js"></script>
<script src="/res/third/laytpl/laytpl.js"></script>
<script src="/res/third/laytpl/template.js"></script>
<script src="/res/third/layer/layer.extends.js"></script>
<script src="/res/third/city-picker/js/city-picker.data.js"></script>
<script src="/res/third/city-picker/js/city-picker.js"></script>
<script src="/res/js/common/common.js"></script>
<script src="/res/js/common/lazyload.js"></script>


<script type="text/javascript">  
 	$(function(){
 		$(".store.flr>div.iterm2.proType table .fanYe a").hover(function(){
 			$(this).siblings(".nav").addClass("on");
 		},function(){
 			$(this).siblings(".nav").removeClass("on");
 		})
 	})
    var searchParam={keywords:'${(param.keywords)!}',categoryIds:"${(param.categoryIds)!}",pageNo:${param.pageNo!1},orderType:${(param.orderType)!0},provinceCode:"${(param.provinceCode)!''}",cityCode:"${(param.cityCode)!''}" };
    [#--orderType 0默认,创建时间desc,1价格asc,2价格desc,3销量asc,4销量desc,5浏览量asc,6浏览量desc--]
    var selloffer = {
        _tempId:"template",
        _containerId:"products",
        _totalPage:0,
        offerSearch:function (rebuidpage,storestat) {//检索
            var _this =this;
            var data = searchParam;
            $('#keywords').val($.trim(searchParam.keywords));//头部搜索框
            layer.post({
                url:"/selloffer/offer_search",
                data:JSON.stringify(data),
                contentType:"application/json",
                success:function (result) { 
                    //类别
                    var categoryList = result.params.categoryList;
                    var currentcat = result.params.current;//用以三级选中的情况

                    var categoryhtml = template("categorysTemplate",{list:categoryList,currentcat:currentcat});
                    $('#categorySContainer').html(categoryhtml);


                    $("#firstS").html("");
                    $("#secondS").html("");
                    $("#thirdS").html("");
                    var cccat = result.params.ccat;
                    if(cccat){
                        if(cccat.proCategory){
                            if(cccat.proCategory.proCategory){
                                $("#firstS").html(" > <a onclick='changeCatType(this)' attid='"+cccat.proCategory.proCategory.id+"' >"+cccat.proCategory.proCategory.name+"</a>");
                                $("#secondS").html(" > <a onclick='changeCatType(this)' attid='"+cccat.proCategory.id+"' >"+cccat.proCategory.name+"</a>");
                                $("#thirdS").html(" > <a onclick='changeCatType(this)' attid='"+cccat.id+"' >"+cccat.name+"</a>");
                            }else{
                                $("#firstS").html(" > <a onclick='changeCatType(this)' attid='"+cccat.proCategory.id+"' >"+cccat.proCategory.name+"</a>");
                                $("#secondS").html(" > <a onclick='changeCatType(this)' attid='"+cccat.id+"' >"+cccat.name+"</a>");
                            }
                        }else{
                            $("#firstS").html(" > <a onclick='changeCatType(this)' attid='"+cccat.id+"'>"+cccat.name+"</a>");
                        }
                    }



                    //头部分页
                    $("#pageNo").text(result.totalCount==0?1:result.pageNo);
                    $("#pages").text("/ "+result.totalPage);
                    _this._totalPage=result.totalPage;

                    //产品
                    var html = template("template",{list:result.list,total:result.totalCount});
                    $('#products').html(html);
                    initImageLoad();

                    if(rebuidpage){
                        //底部分页
                        _this.layerPage(result.totalPage,_this);
                    }

                    if(!storestat){
                        //地区选择
                        _this.initCityPicker();
                    }


                    //保存状态
                    _this.pushUrl(storestat);
                    $(".godName.product").each(function(){
                    	$(this).ellipsis({maxWidth:180,maxLine:2});
                	});

                    $(".store.fll ul.hot.proType li>span a").each(function(){
                    	$(this).ellipsis({maxWidth:180,maxLine:2});
                	});

                    $(".store.flr .iterm2 ul.proType li a.godName.product").each(function(){
                    	$(this).ellipsis({maxWidth:150,maxLine:2});
                	});

                    _this.replaceToRed();
                }
            });
        },
        pushUrl:function(storestat,path){//path:url参数 ,storestat ,是否保存状态

            var href = path || location.href.split("?")[0];
            var params=[];
            if(searchParam.categoryIds!=""){
                params.push("categoryIds="+searchParam.categoryIds);
            }
            if(searchParam.orderType!=0){
                params.push("orderType="+searchParam.orderType);
            }
            if(searchParam.provinceCode!=""){
                params.push("provinceCode="+searchParam.provinceCode);
            }
            if(searchParam.cityCode!=""){
                params.push("cityCode="+searchParam.cityCode);
            }
            if(searchParam.keywords!=""){
                params.push("keywords="+searchParam.keywords);
            }
            if(searchParam.pageNo!=1){
                params.push("pageNo="+searchParam.pageNo);
            }

            var paramStr="";
            if(params.length!=0){
                href=href+"?"+params.join("&");
            }
            if ('pushState' in history && storestat ) {
                history.pushState(searchParam,document.title,href);
            }
            return href;
        },
        replaceToRed:function () {
            var keyword = $.trim(searchParam.keywords);
            if(keyword!=""){
                $(".product").each(function () {
                    var text = $(this).text();
                    var html = text.replace(new RegExp($.trim(keyword),'gi'),"<span style='color: red;font-weight: bold' >"+keyword+"</span>");
                    $(this).html(html);
                });
            }
        },
        templateHelper:function(){//模板价格格式化
            template.config("escape", false);
            template.helper('priceFormat', function (price, format) {
                return $.my.currency(price,true);
            });
        },
        layerPage:function (totalPage,_this){//分页

            laypage({
                cont: 'laypage',
                pages: totalPage,
                first:1,
                last: totalPage,
                curr:searchParam.pageNo,
                skin: 'molv',
                jump: function(obj, first) {
                    if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr
//                        location.href="#topsell";
                        window.scrollTo(0,200);
                        searchParam.pageNo=obj.curr;
                        _this.offerSearch(false,true);
                    }
                }
            });
        },
        initCityPicker:function(){//选择地区
            var provinceCode = searchParam.provinceCode;
            var cityCode = searchParam.cityCode;
            var values=[];
            if(provinceCode!=""){
                values.push(ChineseDistricts["no"+provinceCode]);
            }
            if(cityCode!=""){
                values.push(ChineseDistricts[provinceCode][cityCode]);
            }

            $("#areaProvince").val(values.join("/"));

            var hasinit = $("#areaProvince").data("citypicker");
            if(hasinit){
                hasinit.refresh(true,true);
            }
            //地区
            $("#areaProvince").citypicker({canremove:true,level:"city",simple:true,feedValBack:function (v,byhand) {
                var data = $("#areaProvince").data("citypicker");

                if(data){
                    var getcode = $.trim(data.getCode());
                    if(getcode==""){
                        searchParam.provinceCode="";
                        searchParam.cityCode="";
                    }else{
                        if(getcode.indexOf("/")!=-1){
                            var codes = getcode.split("/");
                            searchParam.provinceCode=codes[0];
                            searchParam.cityCode=codes[1];
                        }else{
                            searchParam.provinceCode=getcode;
                        }
                    }
                    searchParam.pageNo=1;
                    if(!byhand){//不是手动调的citypicker的refresh    hasinit.refresh(true,true); ,则要存stat
                        selloffer.offerSearch(true,true);
                    }
                }
            }});
        },
        init:function(fn){
            _this = this;
            if (typeof fn === "function"){
                fn();
            }

           if ('pushState' in history) {
                window.addEventListener("popstate", function (e) {
                    if(history.state){
                        searchParam = history.state;
                        selloffer.offerSearch(true,false);
                    }
                });
            }

            this.templateHelper();
            this.offerSearch(true,true);
            this.initCityPicker();
            return this;
        }
    }.init(function(){
        //上一页
        $("#prevPage").click(function(){
            searchParam.pageNo=searchParam.pageNo>1?searchParam.pageNo-1:1;
            selloffer.offerSearch(true,true);
        });
        //下一页
        $("#nextPage").click(function(){
            searchParam.pageNo=searchParam.pageNo < selloffer._totalPage?searchParam.pageNo+1:selloffer._totalPage;
            selloffer.offerSearch(true,true);
        })
    });

    function changeCatType(obj){
        var attid = $(obj).attr("attid");
        searchParam.categoryIds=attid;
        searchParam.pageNo=1;
        selloffer.offerSearch(true,true);
    }
    
    //选择类别
    function searchByCategory(categoryid) {
        if(searchParam.categoryIds != categoryid){
            searchParam.categoryIds=categoryid;
            searchParam.pageNo=1;
            selloffer.offerSearch(true,true);
        }
    }

    /**
     * 更多
     * */
    function more(obj) {
        $(obj).parent().prev().height("auto");
        $(obj).replaceWith('<a class="shouQiLink" onclick="less(this)">收起<i class="zhanKai shouQi"></i></a>');
    }

    /**
     * 收起
     * */
    function less(obj) {
        $(obj).parent().prev().height("20px");
        $(obj).replaceWith('<a class="zhanKaiLink" onclick="more(this)">更多<i class="zhanKai"></i></a>');
    }

    /**
     * 排序
     * */
    function switchTab(obj, name) {
        var otype = searchParam.orderType;
        if(name=="price"){

            $("#numswitch").removeClass("desc").addClass("desc");
            if(otype==1){
                searchParam.orderType=2;
                $(obj).find("i:eq(1)").addClass("on");
                $(obj).find("i:eq(0)").removeClass("on");
            }else{
                searchParam.orderType=1;
                $(obj).find("i:eq(0)").addClass("on");
                $(obj).find("i:eq(1)").removeClass("on");
            }
        }else if(name=="num"){
            $("#priceswitch").find("i").removeClass("on");
            if(otype==4){
                searchParam.orderType=3;
            }else{
                searchParam.orderType=4;
            }
        }else{
            $("#priceswitch").find("i").removeClass("on");
            $("#numswitch").removeClass("desc").addClass("desc");
            searchParam.orderType=0;
        }
        selloffer.offerSearch(false,true);
        $(obj).toggleClass("desc");
    } 
</script>
</html>